package com.example.hangzhou.welbeing.mytestdemoapp.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.transition.ChangeImageTransform;
import android.transition.TransitionManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.hangzhou.welbeing.mytestdemoapp.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 杭州惟君医疗科技有限公司10
 * Created by 20433 on 2018/5/9
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class ChangeImageTransformFragment extends Fragment {
    @Bind(R.id.fragment_transition_note_change_image_transform_bt_fit_xy)
    Button fragmentTransitionNoteChangeImageTransformBtFitXy;
    @Bind(R.id.fragment_transition_note_change_image_transform_bt_center)
    Button fragmentTransitionNoteChangeImageTransformBtCenter;
    @Bind(R.id.fragment_transition_note_change_image_transform_bt_center_crop)
    Button fragmentTransitionNoteChangeImageTransformBtCenterCrop;
    @Bind(R.id.fragment_transition_note_change_image_transform_l1)
    LinearLayout fragmentTransitionNoteChangeImageTransformL1;
    @Bind(R.id.fragment_transition_note_change_image_transform_bt_fit_start)
    Button fragmentTransitionNoteChangeImageTransformBtFitStart;
    @Bind(R.id.fragment_transition_note_change_image_transform_bt_fit_end)
    Button fragmentTransitionNoteChangeImageTransformBtFitEnd;
    @Bind(R.id.fragment_transition_note_change_image_transform_bt_matrix)
    Button fragmentTransitionNoteChangeImageTransformBtMatrix;
    @Bind(R.id.fragment_transition_note_change_image_transform_l2)
    LinearLayout fragmentTransitionNoteChangeImageTransformL2;
    @Bind(R.id.fragment_transition_note_change_image_transform_iv_image)
    ImageView fragmentTransitionNoteChangeImageTransformIvImage;
    @Bind(R.id.fragment_transition_note_change_image_transform_l3)
    LinearLayout fragmentTransitionNoteChangeImageTransformL3;
    private Context mcontext;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mcontext = context;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = View.inflate(mcontext, R.layout.fragment_transition_note_change_image_transform, null);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick({R.id.fragment_transition_note_change_image_transform_bt_fit_xy, R.id.fragment_transition_note_change_image_transform_bt_center, R.id.fragment_transition_note_change_image_transform_bt_center_crop, R.id.fragment_transition_note_change_image_transform_bt_fit_start, R.id.fragment_transition_note_change_image_transform_bt_fit_end, R.id.fragment_transition_note_change_image_transform_bt_matrix})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.fragment_transition_note_change_image_transform_bt_fit_xy:
                TransitionManager.beginDelayedTransition(fragmentTransitionNoteChangeImageTransformL3, new ChangeImageTransform());
                fragmentTransitionNoteChangeImageTransformIvImage.setScaleType(ImageView.ScaleType.FIT_XY);
                break;
            case R.id.fragment_transition_note_change_image_transform_bt_center:
                TransitionManager.beginDelayedTransition(fragmentTransitionNoteChangeImageTransformL3, new ChangeImageTransform());
                fragmentTransitionNoteChangeImageTransformIvImage.setScaleType(ImageView.ScaleType.CENTER);
                break;
            case R.id.fragment_transition_note_change_image_transform_bt_center_crop:
                TransitionManager.beginDelayedTransition(fragmentTransitionNoteChangeImageTransformL3, new ChangeImageTransform());
                fragmentTransitionNoteChangeImageTransformIvImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
                break;
            case R.id.fragment_transition_note_change_image_transform_bt_fit_start:
                TransitionManager.beginDelayedTransition(fragmentTransitionNoteChangeImageTransformL3, new ChangeImageTransform());
                fragmentTransitionNoteChangeImageTransformIvImage.setScaleType(ImageView.ScaleType.FIT_START);
                break;
            case R.id.fragment_transition_note_change_image_transform_bt_fit_end:
                TransitionManager.beginDelayedTransition(fragmentTransitionNoteChangeImageTransformL3, new ChangeImageTransform());
                fragmentTransitionNoteChangeImageTransformIvImage.setScaleType(ImageView.ScaleType.FIT_END);
                break;
            case R.id.fragment_transition_note_change_image_transform_bt_matrix:
                TransitionManager.beginDelayedTransition(fragmentTransitionNoteChangeImageTransformL3, new ChangeImageTransform());
                fragmentTransitionNoteChangeImageTransformIvImage.setScaleType(ImageView.ScaleType.MATRIX);
                break;
        }
    }
}
